package cn.study.controller;


import cn.study.entity.StudyFavorite;
import cn.study.service.StudyFavoriteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@Slf4j
public class StudyCollectController {


    @Resource
    StudyFavoriteService studyFavoriteService;



    @RequestMapping("sel")
    public String sel(Integer id, Model model)
    {

        List<StudyFavorite> list=studyFavoriteService.getlist(id);
        model.addAttribute("list",list);
        System.out.println("asdasdasdsadasdasdasdasdasd"+list);
        return "study_collect";
    }


    @RequestMapping("del")
    public  String del(Integer id)
    {
        boolean bl=studyFavoriteService.removeById(id);
        if(bl){
            log.info("删除成功");
        }else {
            log.info("删除失败");
        }
        return "redirect:/sel";
    }
}
